﻿using Garfield.Core.Runtime;

namespace Garfield.Core
{
    [Plugin("Garfield.Core")]
    public class CorePlugin : Plugin
    {
        public const string ADAPTER_FACTORIES = "Garfield.Core.AdapterFactories";
        public static readonly ExtensionPoint<IAdapterFactory> AdapterFactories = DeclareExtensionPoint<IAdapterFactory>(typeof(CorePlugin), ADAPTER_FACTORIES, true);

        protected override void Initialize()
        {            
        }

        public override void Start(IServiceLocator serviceLocator)
        {
            Adapters.AdapterFactories = serviceLocator.GetService<IExtensionRegistry>().GetExtensions(AdapterFactories);
        }

        public override void Stop(IServiceLocator serviceLocator)
        {
            Adapters.AdapterFactories = null;
        }
    }
}
